import Vue from "vue";
import ElementUI from "element-ui";
import "element-ui/lib/theme-chalk/index.css";
import "element-ui/lib/theme-chalk/display.css";
import App from "./App.vue";
import router from "./router";
import store from "./store";
// 导入md5.js
import MD5 from "js-md5";
// 将md5转换成vue原型：
Vue.prototype.md5 = MD5;
// 导入全局CSS
import "./assets/css/global.css";

import * as echarts from "echarts";

// 导入校验规则
import Roles from "./plugins/formRoles";
import Language from "./plugins/Language";
// 引入全局 Table
import Table from "./components/table/table";
// 格式化输出 Date
import "./plugins/Date";
import DonMessage from "./plugins/Message";
// menu icon
import { icon } from "./plugins/Icon";
// 导入自定义组件
import components from "./components/public/components";
import { LoadMore } from "./plugins/LoadMore";
import common from "./plugins/Common";
import Download from "./plugins/Download";
Vue.use(Download);
Vue.use(Table);
Vue.prototype.$rules = Roles;
Vue.prototype.$icon = icon;
Vue.prototype.$common = common;

Vue.prototype.$echarts = echarts;
Vue.use(LoadMore);

Vue.use(DonMessage);
// 命名根据需要，DonMessage只是在文章中使用

// import Shios from "./plugins/shios";
import { Shios } from "shios";
Vue.prototype.$http = Shios.create({ baseUrl: process.env.VUE_APP_BASEURL });

Vue.prototype.$http.message = Vue.prototype.$message;
Vue.prototype.$http.IsShowLog = false;
Vue.prototype.$http.UrlToLowerCase = true;
Vue.prototype.$http.verifyState = (response) => {
  if (response.data.Code !== 200) {
    Vue.prototype.$message.error(response.data.Message);
    throw response;
  }
};

Vue.prototype.$http.assert = (response) => {
  if (typeof response.data.Data !== "string" && response.data.Code === 200) {
    Vue.prototype.$message.success(response.data.Message);
  }
};

Vue.prototype.$alipay = new Shios({ baseUrl: process.env.VUE_APP_ALIPAYURL });
Vue.prototype.$alipay.message = Vue.prototype.$message;
Vue.prototype.$alipay.IsShowLog = true;
Vue.prototype.$alipay.UrlToLowerCase = false;
Vue.prototype.$alipay.verifyState = (response) => {
  if (response.data.isError) {
    Vue.prototype.$message.error(response.data.subMsg);
    throw response;
  }
};
// Vue.prototype.$alipay.assert = (response) => {
//   if (!response.data.isError && response.data.msg) {
//     Vue.prototype.$message.success(response.data.msg);
//   }
// };

Vue.use(ElementUI);
ElementUI.Button.props.size.default = "mini";
console.log();

// Vue.use(Language);
Vue.prototype.$language = Language;

Vue.use(components);

Vue.config.productionTip = false;

new Vue({
  router,
  store,
  render: (h) => h(App),
}).$mount("#app");
